import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'layout',
    component:()=> import("../layout/layout.vue"),
    children: [
      //  智能监控  
      {
        path: '/workingTable',
        component: () => import('./../views/monitoring/monitoringnd.vue'),
      },{
        path: '/workingTable/linkage',
        component: () => import('./../views/monitoring/monitoringnr.vue'),
      },
      // 车辆管理
      {
        path: '/vehicle',
        component: () => import('./../views/vehicle/vehicle.vue'),
      },{
        path: '/vehicle/vehicleca',
        component: () => import('./../views/vehicle/vehicleca.vue'),
      },{
        path: '/vehicle/vehicleda',
        component: () => import('./../views/vehicle/vehicleda.vue'),
      },{
        path: '/vehicle/vehiclede',
        component: () => import('./../views/vehicle/vehiclede.vue'),
      },
      // 人员管理
      ,{
        path: '/Personnck',
        component: () => import('./../views/personnel/Personnck.vue'),
      },{
        path: '/personnel/Personndl',
        component: () => import('./../views/personnel/Personndl.vue'),
      },{
        path: '/personnel/Personnel',
        component: () => import('./../views/personnel/Personnel.vue'),
      },{
        path: '/personnel/Personnen',
        component: () => import('./../views/personnel/Personnen.vue'),
      },
      //安全管理
      ,{
        path: '/securita',
        component: () => import('./../views/security/securita.vue'),
      },{
        path: '/security/securitd',
        component: () => import('./../views/security/securitd.vue'),
      },{
        path: '/security/securite',
        component: () => import('./../views/security/securite.vue'),
      },{
        path: '/security/securito',
        component: () => import('./../views/security/securito.vue'),
      },{
        path: '/security/security',
        component: () => import('./../views/security/security.vue'),
      },
      //能耗管理
      {
        path: '/energy',
        component: () => import('./../views/energy/energe.vue'),
      },{
        path: '/energy/energg',
        component: () => import('./../views/energy/energg.vue'),
      },
      //洗车洗盒
      {
        path: '/thecar',
        component: () => import('./../views/thecar/thecad.vue'),
      },{
        path: '/thecar/thecar',
        component: () => import('../views/thecar/thecar.vue'),
      }, 
       // 资产
      {
        path: '/assetd',
        component: () => import('./../views/assets/assetd.vue'),
      },{
        path: '/assets',
        component: () => import('./../views/assets/assets.vue'),
      },
      //园区
      {
        path: '/hepard',
        component: () => import('./../views/hepark/hepard.vue'),
      },{
        path: '/hepark',
        component: () => import('./../views/hepark/hepark.vue'),
      },
      // 系统设置
      {
        path: '/system',
        component: () => import('./../views/system/system.vue'),
      },{
        path: '/systen',
        component: () => import('./../views/system/systen.vue'),
      },
    ],  
  },
  {
    path: '/login',
    name: 'login',
    component: () => import("./../views/login/login.vue")
  }
]

const router = new VueRouter({
  routes
})

router.beforeEach((to,from,next)=>{
  const global=JSON.parse(localStorage.getItem('global')||'{}')
  const whites=['/login']
  if(!global.token&&!whites.includes(to.path)){
    return 
  }
  next()
})

export default router
